<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="./css/mui.min.css">
		<link rel="stylesheet" href="./css/swiper.css">
		<style>
			html,body {
				background-color: #efeff4;
			}
			.title{
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}
		</style>
	</head>
	<body>
	
		<div class="mui-content" style="background-color:#fff">
			<div class="swiper-container">
			  <div class="swiper-wrapper">
			    <div class="swiper-slide">slider1</div>
			    <div class="swiper-slide">slider2</div>
			    <div class="swiper-slide">slider3</div>
			  </div>
			</div>
		    <h5 style="background-color:#efeff4">慢生活</h5>
		    
		    <ul class="mui-table-view mui-grid-view" id="images">
		        
		    </ul>    
		</div>
	
	</body>
	<script src="./js/mui.min.js"></script>
	<script src="./js/swiper.js"></script>
	
	<script>
		mui.init({
			swipeBack:true ,//启用右滑关闭功能
			preloadPages:[{
			    id:'detail.html',
			    url:'detail.html'           
			  }
			  ]
		});
		
		var detailPage = null;
			//添加列表项的点击事件
		
		var mySwiper = new Swiper('.swiper-container', {
				autoplay: 5000,//可选选项，自动滑动
			})
		
		mui.ajax('http://myxiu.wang/shop/shophome/api',{
			dataType:'json',//服务器返回json格式数据
			type:'get',//HTTP请求类型
			success:function(ret){
				var html = '';
				if(ret){
					for(var i=0;i<ret.length;i++){
					 
					html+= '<li class="mui-table-view-cell mui-media mui-col-xs-6" id="aa" data-id="'+ret[i].id+'"><a href="#"><img class="mui-media-object" src="http://yiipic.xiuyun99.com/'+ret[i].img+'@228w_210h_1e_1c"><div class="mui-media-body">'+ret[i].title+'</div></a></li>';
					}
					document.getElementById('images').innerHTML=html;
				}else{
					//api.alert({msg:('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode)});
				}
			}
		});
		
		mui('.mui-table-view').on('tap', '.mui-table-view-cell', function(e) {
			  var id = this.getAttribute('data-id');
			  //获得详情页面
			  if(!detailPage){
			    detailPage = plus.webview.getWebviewById('detail.html');
			  }
			  //触发详情页面的newsId事件
			  mui.fire(detailPage,'newsId',{
			    id:id
			  });
			//打开详情页面 
			
			  mui.openWindow({
			    id:'detail.html'
			  });
			
		})
	</script>
</html>